import type { AttrResponseDate, CategoryResponseData,Attr } from "./type";
//属性相关api
import { request } from "@/utils/request";
enum API{
    //获取一级分类的接口地址
    C1_URL = "/admin/product/getCategory1",
    //获取二级分类的方法
    C2_URL = "/admin/product/getCategory2/",
    //获取三级分类的接口地址
    C3_URL = "/admin/product/getCategory3/",
    //获取分类下已有属性与属性值
    ATTR_URL = '/admin/product/attrInfoList/',
    //添加修改商品属性
    ADDORUPDATEATTR_URL='/admin/product/saveAttrInfo',
    //删除商品属性
    DELETEDATA_URL='/admin/product/deleteAttr/'
}

//获取一级分类的接口方法
export const reqC1 = ()=>request.get<any,CategoryResponseData>(API.C1_URL)
//获取二级分类的接口方法
export const reqC2 = (category1Id:number|string)=>request.get<any,CategoryResponseData>(API.C2_URL+category1Id)
//获取三级分类的接口方法
export const reqC3 = (category2Id:number|string)=>request.get<any,CategoryResponseData>(API.C3_URL+category2Id)
//获取对应分类下的已有属性与属性接口
export const reqAttr = (category1Id:number|string,category2Id:number|string,category3Id:number|string)=>request.get<any,AttrResponseDate>(API.ATTR_URL+`${category1Id}/${category2Id}/${category3Id}`);
//新增或者修改已有属性的接口
export const reqAddOrUpdataAttr = (data:Attr)=>request.post<any,any>(API.ADDORUPDATEATTR_URL,data)
//删除属性接口方法
export const delAttr = (attrId:number)=>request.delete<any,any>(API.DELETEDATA_URL+attrId)
